<html>
<head>
<script type="text/javascript">
function getElements(key) {
  var x=document.getElementsByName(key);
  alert(x.length + " inputs for name " + key);
  }
</script>
</head>
<body>

<input name="myInput" type="text" size="20" /><br />
<input name="myInput" type="text" size="20" /><br />
<input name="myInput" type="text" size="20" /><br />
<br />
<input type="button" onclick="getElements('myInput')"
value="How many elements named 'myInput'?" />

<input type="button" onclick="getElements('data')"
value="How many elements named 'data'?" />

</body>
</html>